import { defineStore } from 'pinia';

export const useUserStore = defineStore('userInfo', {
    state: () => {
        return {
            token: '',
            userInfo: null as any,
            username: 'admin'

        };
    },

    actions: {
        getToken(t: any) {
            this.token = t
            console.log(this.token);
        },

        async fetchUserInfo() {
            //调接口   获取用户信息
            if (this.token) {
                console.log('fetchUserInfo');
                this.userInfo = {
                    name: 'xue',
                    age: '22'
                }

            }
        },
        userLogout(){}
    },
    persist: true
});